package com.note.servlet.mail;

import com.note.utils.Mail;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

public class sendCode extends HttpServlet{

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
            throws ServletException, IOException
    {
        String code = "";
        for(int i=0;i<6;i++){
            String c = String.valueOf(new Random().nextInt(10));
            code += c;
        }
        PrintWriter out = response.getWriter();

        String to="2196447160@qq.com";
        String subject="修改密码";
        String msg= "<h1>"+code+"</h1><h3>,5分钟内有效</h3>";

        try {
            Mail.sendMsg(to, subject, msg);
            System.out.println("666");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("666");
        }
        out.print(code);
        out.close();
    }
} 